from rest_framework import serializers
from apps.recruit.models import City, Recruit, Enterprise


class CitySerializer(serializers.ModelSerializer):
    """
        城市序列化器
    """

    class Meta:
        # 指定根据哪个模型类生成对应的序列化器字段
        model = City
        fields = "__all__"

        # extra_kwargs = {
        #     # key值为要修改的字段的参数,value值为修改的选项内容
        #     'bread': {
        #         'max_value': 100,
        #         'min_value': 0,
        #         'default': 0
        #     }
        # }


class JobSerializer(serializers.ModelSerializer):
    """
    职位信息
    """

    class Meta:
        model = Recruit
        fields = "__all__"


class CompanySerializer(serializers.ModelSerializer):
    """
    公司信息
    """
    recruits = JobSerializer(read_only=True,many=True)

    class Meta:
        model = Enterprise
        fields = "__all__"
        extra_kwargs = {
            'users': {
                'many': True
            }
        }
